# flask���������ĵ�
# https://dormousehole.readthedocs.io/en/latest/quickstart.html
from flask import Flask,request,jsonify
app = Flask(__name__)


operationList = []
userID = 1000

@app.route("/")
def hello_world():
    return "Hello, World!"
#test function(can be ignored)

@app.route("/getUserID")
def getUserID():
    global userID
    user_id = str(userID)
    userID = userID + 1
    return jsonify(mode = 1,userID=user_id)
    
@app.route("/submit",methods = ["GET"])
def submit():
    x = request.args.get('x')
    y = request.args.get('y')
    user_id = request.args.get('userID')
    
    if user_id is None:
        return jsonify(mode=0,msg="empty userID")
    print(user_id)
    tmp = dict()
    tmp['x'] = x
    tmp['y'] = y
    tmp['userID'] = user_id
    operationList.append(tmp)
    return jsonify(mode = 3,msg="success")


@app.route("/getOperationLists")
def getlist():
    return jsonify(mode=2,operationList=operationList)